<template>
	{{obj.city}}
	<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
		<swiper-item v-for="item in obj.data" :key="item.id">
			<view class="swiper-item">
				<image :src="'https://jk.136.dianchuiguan.com.cn'+item.url" mode=""></image>
			</view>
		</swiper-item>
		
	</swiper>
	  <view class="">题库已更新</view>
<view class="flex carttype">
	
  <navigator :url="'/indexsub/testdone/testdone?cart='+(index+1)+'&title='+item.text" v-for="(item,index) in cartType" :key="item.id">
  	 <image :src="item.imgUrl" mode=""></image>
	 <view class="">{{item.text}}</view>
	 <view class="">{{item.texten}}</view>
  </navigator> 
</view>
	  
</template>

<script>
	import {mapState,mapActions} from "pinia";
	import {useUserStore} from "@/stores/user.js";
	import {ajaxFun} from "@/untils/ajax.js"
	export default {
		onLoad() {
			//做判断
		   let userInfo=uni.getStorageSync("user");
		   if(!userInfo){
		   	uni.reLaunch({
		   		url:"/pages/login/login"
		   	})
		   }
		   //获取轮播图
		   this.getData()
		},
		data(){
			return {
				obj:{},
				cartType:[
					{
						id:1,
						text:"小车",
						texten:"c1/c2/c3",
						// /indexsub/images/index/hc.png
						imgUrl:"../../static/images/index/xc.png"
					},
					{
						id:2,
						text:"货车",
						texten:"c1/c2/c3",
						imgUrl:"../../static/images/index/hc.png"
					},
					{
						id:3,
						text:"客车",
						texten:"c1/c2/c3",
						imgUrl:"../../static/images/index/kc.png"
					},
					{
						id:4,
						text:"摩托车",
						texten:"c1/c2/c3",
						imgUrl:"../../static/images/index/mtc.png"
					}
				]
			}
		},
		computed:{
			...mapState(useUserStore,["location","userInfo"])
		},
		methods:{
			
		  async getData(){
			  let result=await ajaxFun("/index/banner","get",{
				  lat:this.location.longitude,
				  lon:this.location.latitude,
				  userid:this.userInfo.userid
			  })
			  this.obj=result
		  }
		}
		
	}
</script>

<style lang="scss" scoped>
	image{
		width: 100%;
		height: 520rpx;
	}
	.flex{
		display: flex;
		justify-content: space-around;
	}
	.carttype{
		text-align: center;
		 image{
			 width: 100rpx;
			 height: 100rpx;
		 }
	}
</style>
